/** 
* Descripttion:  Copyright (c) 2020 Deepblue. All rights reserved.
* version:  V1.0 
* Author:  Deepblue
* Date: 2020-10-21 13:06:43
* LastEditors:  Deepblue
* LastEditTime: 2020-10-22 09:04:17
**/
#include <iostream>
#include <memory>
#include <vector>
#include <assert.h>


#include <gtest/gtest.h>

using namespace std;

class name
{
public:
    name() {std::cout << "name constructor" << std::endl;}
    ~name() {std::cout << "name destructor" << std::endl;}

    /** 
    * description: 
    * param {*}
    * return {*}
    **/
    void myprint(){
        std::cout << "myprint" << std::endl;
    }
 
    static void test(){
        std::cout << "static test" << std::endl;
    }

    bool flag(){
        return false;
    }

//    static int v = 0;
};

void test(){
    std::vector<std::unique_ptr<int>> vec;
    std::unique_ptr<int> u1(new int(1));
    vec.push_back(std::unique_ptr<int>(new int(2)));
    vec.push_back(std::move(u1));

    std::vector<std::unique_ptr<name>> vec1;
    std::unique_ptr<name> u2(new name);
    std::unique_ptr<name> u3 = std::forward<std::unique_ptr<name>>(u2);
    vec1.push_back(std::move(u2));
    vec1.push_back(std::unique_ptr<name>(new name()));
}

void test_shared(){
    std::shared_ptr<int> s1(new int(1));
    std::cout << "s1.use_count: " << s1.use_count() << std::endl;
    std::shared_ptr<int> s2 = s1;

    std::cout << "s1.use_count: " << s1.use_count() << std::endl;

    // 会导致运行时错误
    std::shared_ptr<int> s3(s1.get());
    std::cout << "s3.use_count: " << s3.use_count() << std::endl;

    std::shared_ptr<int> s4 = s1;
}


TEST(test_name, myprint)
{
    name n;
    n.myprint();
    assert(0);
    std::cout << "================" << std::endl;
    // ASSERT_TRUE(n.flag()) << "age is not 16";
}

TEST(test_name, myprint1)
{
    int x = 16;
    int y = x >> 3;

    std::cout << "y = " << y << std::endl;
}
